<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button{
            width: 200px;
            height: 50px;
            background: linear-gradient(to right,red,green,yellow);
            color: white;
            text-align: center;
            line-height: 50px;
            font-size: 18px;
            border-radius: 10px;
        }
        #app{
            display: flex;
            justify-content: center;
            align-items: center;
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            width: 100%;
            height: 100%;
            background-color: rgb(0, 0, 0,.3);
        }
        #app_box{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            width: 300px;
            height: 300px;
            background:linear-gradient(to right,pink,hotpink,purple) ;
            border-radius: 10px;
        }
        .center{
            margin: 20px;
        }
    </style>
</head>
<body>
    <div id="box">
        <button @click="flag=true">沙漠孤狼</button>
        <like :a="flag" @receipt="close"></like>
    </div>

    <template id="like">
        <div id="app" v-if="a">
            <div id="app_box">
                <div class="top">
                    请问
                </div>
                <div class="center">
                    你还爱我吗?
                </div>
                <button @click="enter">我爱你</button>
            </div>
        </div>
    </template>

    <script src='https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js'></script>
    <script>
        Vue.component('like',{
            template:"#like",
            props: ['a'],
            data(){
                return {
                    
                }
            },
            methods:{
                enter(){
                    this.$emit('receipt')
                }
            }
        })


        let vm = new Vue({
            el:'#box',
            data :{
                flag : false
            },
            methods: {
                close(){
                    this.flag=false
                }
            }
        })


    </script>
</body>
</html>